package com.qf.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @author sunyamei
 * @version V1.0
 * @Project javase2203
 * @Package com.qf.filter
 * @Description:
 * @Date 2022/8/12 10:19
 */
@Component
public class Filter1 implements Ordered, GlobalFilter {

    /**
     * 执行业务
     * @param exchange
     * @param chain
     * @return
     */
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        System.out.println("=====这里是Filter1=====");
        //执行下一个过滤器,如果没有下一个过滤器,执行微服务的controller方法
        //相当于放行

        return chain.filter(exchange);
    }


    /**
     * 如果有多个过滤器,过滤器的执行顺序
     * @return
     */
    @Override
    public int getOrder() {
        return 0;
    }
}
